"""
基于sklearn实现nn，并对比自己实现与sklearn的方法的精度
"""
import numpy as np
from sklearn import datasets
import matplotlib.pyplot as plt
from sklearn.metrics import accuracy_score
from sklearn.neural_network import MLPClassifier
from sklearn.preprocessing import StandardScaler

np.random.seed(0)
X, y = datasets.make_moons(200, noise=0.20)

scaler = StandardScaler()
scaler.fit(X)
X_b = scaler.transform(X)
clf_class = MLPClassifier(solver='sgd', activation='logistic', alpha=0.01, hidden_layer_sizes=8, max_iter=2000)
clf_class.fit(X_b, y)
y_pred = clf_class.predict(X)
acc = accuracy_score(y, y_pred)
print('MLPClassifier准确率:%f' % acc)
